﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BCNPCObject;
using BCNPCObject.DB;

namespace bus_TienichNPC
{
    public class CN_THEODOINO_bus
    {
        CN_THEODOINO_Control cn_ctr = new CN_THEODOINO_Control();

        public CN_THEODOINO_bus()
        {

        }

        public DataSet SELECT_HDON_STT(string strMaDviqly, string PMA_SOGCS,string CHECK, string PSTT)
        {
            String strErr = "";
            DataSet ds = new DataSet();
            try
            {
                CMIS2.DB.SELECT_HDON_STT(strMaDviqly, PMA_SOGCS,CHECK, PSTT, out ds);
                return ds;
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
            }

        }

        public DataSet SELECT_HDON_THEOFILE_TRUNG(string strMaDviqly, string PMA_TNGAN)
        {
            String strErr = "";
            DataSet ds = new DataSet();
            try
            {
                CMIS2.DB.SELECT_HDON_THEOFILE_TRUNG(strMaDviqly, PMA_TNGAN, out ds);
                return ds;
            }
            catch (Exception ex)
            {                
                return null;
            }
            finally
            {
            }

        }

        public DataSet SELECT_CHAMNO_THEOFILE(string strMaDviqly, Int64 PSTT, string PMA_SOGCS, string check, ref string Err)
        {
            String strErr = "";
            DataSet ds = new DataSet();
            try
            {
                CMIS2.DB.SELECT_CHAMNO_THEOFILE(strMaDviqly, PSTT, PMA_SOGCS, check, out ds);
                return ds;
            }
            catch (Exception ex)
            {
                strErr = ex.ToString();
                return null;
            }
            finally
            {
            }

        }

        public DataSet CN_So_BBGiao_Nutgoc(string ma_tngan, string ma_dvqly)
        {
            return cn_ctr.CN_So_BBGiao_Nutgoc(ma_tngan, ma_dvqly);
        }

        public DataSet CN_So_BBGiao_Nutcha(string ma_tngan, int so_BBGIAO, string ma_dvqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.CN_So_BBGiao_Theonut(ma_dvqly, ma_tngan, so_BBGIAO, "", 1, out data);
            return data;
        }

        public DataSet CN_So_BBGiao_Nutcon(string ma_tngan, int so_BBGIAO, string Ma_SoGCS, string ma_dvqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.CN_So_BBGiao_Theonut(ma_dvqly, ma_tngan, so_BBGIAO, Ma_SoGCS, 2, out data);
            return data;
        }

        public DataSet ATM_Ton_Select(string ma_tngan, string ma_dvqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_ATM(ma_dvqly, ma_tngan, out data);
            return data;
        }

        public DataSet CN_Select(string ma_tngan, string ma_dvqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_HDON_TON(ma_dvqly, ma_tngan, out data);
            return data;
        }

        public DataSet Ten_Tngan(string ma_dviqly, string ma_tngan)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TEN_TNGAN(ma_dviqly, ma_tngan, out data);
            return data;
        }

        public DataSet Load_TNV(string ma_dviqly)
        {
            return cn_ctr.Load_TNV(ma_dviqly);
        }

        public DataSet Catdien_Nutgoc(string ma_dvqly, DateTime ngay)
        {
            return cn_ctr.Catdien_Nutgoc(ma_dvqly, ngay);
        }

        public DataSet Catdien_Nutcha(string ma_tngan, string ma_dvqly, DateTime ngay)
        {
            return cn_ctr.Catdien_Nutcha(ma_tngan, ma_dvqly, ngay);
        }

        public DataSet Catdien_Nutcha2(string ma_tngan, Int64 so_BBGIAO, string ma_dvqly, DateTime ngay)
        {
            return cn_ctr.Catdien_Nutcha2(ma_tngan, so_BBGIAO, ma_dvqly, ngay);
        }

        public DataSet Catdien_Nutcon(string ma_tngan, Int64 so_BBGIAO, string Ma_SoGCS, string ma_dvqly, DateTime ngay)
        {
            return cn_ctr.Catdien_Nutcon(ma_tngan, so_BBGIAO, Ma_SoGCS, ma_dvqly, ngay);
        }

        public DataSet select_ThuNganVien(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_DACHAM(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_TNGAN_HD_TON(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_HD_TON(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_HDON_TON_NUTTNGAN(string ma_dvqly, string ma_tngan)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_HDON_TON(ma_dvqly, ma_tngan, out data);
            return data;
        }

        public DataSet SELECT_HD_TON_THEONUT(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_HD_TON(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_CHAMNO_OFFLINE_ALL(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_CHAMNO_OFFLINE(ma_dviqly, "", 0, "", 0, out data);
            return data;
        }

        public DataSet SELECT_CHAMNO_OFFLINE_NUTCHA(string ma_dviqly, string ma_tngan)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_CHAMNO_OFFLINE(ma_dviqly, ma_tngan, 0, "", 1, out data);
            return data;
        }

        public DataSet SELECT_CHAMNO_OFFLINE_NUTSO_BBG(string ma_dviqly, string ma_tngan, int SO_BBGIAO)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_CHAMNO_OFFLINE(ma_dviqly, ma_tngan, SO_BBGIAO, "", 2, out data);
            return data;
        }

        public DataSet SELECT_CHAMNO_OFFLINE_NUTSO_GCS(string ma_dviqly, string ma_tngan, int SO_BBGIAO, string MA_SOGCS)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_CHAMNO_OFFLINE(ma_dviqly, ma_tngan, SO_BBGIAO, MA_SOGCS, 3, out data);
            return data;
        }

        public DataSet SELECT_TNGAN_THEOBBGIAO(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_THEOBBGIAO(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_TNGAN_ATM(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_ATM(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_ATM_NUT_TNGAN(string ma_dviqly, string MA_TNGAN)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_GDICH_ATM(ma_dviqly, MA_TNGAN, 0, "", 1, out data);
            return data;
        }

        public DataSet SELECT_ATM_NUTGOC(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_GDICH_ATM(ma_dviqly, "", 0, "", 0, out data);
            return data;
        }

        public DataSet SELECT_ATM_NUT_SOBBGIAO(string ma_dviqly, string MA_TNGAN, int SO_BBGIAO)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_GDICH_ATM(ma_dviqly, MA_TNGAN, SO_BBGIAO, "", 2, out data);
            return data;
        }

        public DataSet SELECT_ATM_NUT_MASOGCS(string ma_dviqly, string MA_TNGAN, int SO_BBGIAO, string MA_SOGCS)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_GDICH_ATM(ma_dviqly, MA_TNGAN, SO_BBGIAO, MA_SOGCS, 3, out data);
            return data;
        }

        public DataSet SELECT_TNGAN_ALL(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_ALL(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_HDON(string ma_dviqly, string MA_TNGAN)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_HDON(ma_dviqly, MA_TNGAN, out data);
            return data;
        }

        public DataSet SELECT_THONGTIN_KHANG(string ma_dviqly, string MA_KHANG)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_THONGTIN_KHANG(ma_dviqly, MA_KHANG, out data);
            return data;
        }

        public DataSet SELECT_THONGTIN_KHANG_CHODUYET(string ma_dviqly, string MA_KHANG)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_THONGTIN_KHANG_CHODUYET(ma_dviqly, MA_KHANG, "", 0, out data);
            return data;
        }

        public DataSet SELECT_THONGTIN_KHANG_CHODUYET_TNGAN(string ma_dviqly, string MA_TNGAN)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_THONGTIN_KHANG_CHODUYET(ma_dviqly, "", MA_TNGAN, 1, out data);
            return data;
        }

        public void INSERT_THONGTIN_KHACHHANG(string MA_DVIQLY, string MA_KHANG, string DCHI, string SDT, string WEBSITE,
            string EMAIL, DateTime NGAY_SINH, string FAX, string SO_CMT, DateTime NGAY_CAP, string NOI_CAP,
            string MA_TNGAN, string TEN_KHANG)
        {
            CMIS2.DB.THONGTIN_KHACHHANG(MA_DVIQLY, MA_KHANG, DCHI, SDT, WEBSITE, EMAIL, NGAY_SINH, FAX, SO_CMT, NGAY_CAP, NOI_CAP,
                MA_TNGAN, DateTime.Now, "False", TEN_KHANG, 0);
        }

        public void UPDATE_THONGTIN_KHACHHANG(string MA_DVIQLY, string MA_KHANG, string DCHI, string SDT, string WEBSITE,
            string EMAIL, DateTime NGAY_SINH, string FAX, string SO_CMT, DateTime NGAY_CAP, string NOI_CAP,
            string MA_TNGAN, string TRANG_THAI, string TEN_KHANG)
        {
            CMIS2.DB.THONGTIN_KHACHHANG(MA_DVIQLY, MA_KHANG, DCHI, SDT, WEBSITE, EMAIL, NGAY_SINH, FAX, SO_CMT, DateTime.Now, NOI_CAP,
                MA_TNGAN, DateTime.Now, TRANG_THAI, TEN_KHANG, 1);
        }

        public void UPDATE_TRANGTHAI_KHACHHANG(string MA_DVIQLY, string MA_KHANG, string DCHI, string SDT, string WEBSITE,
            string EMAIL, DateTime NGAY_SINH, string FAX, string CMT, DateTime NGAY_CAP, string NOI_CAP,
            string TRANG_THAI, string TEN_KHANG)
        {
            CMIS2.DB.THONGTIN_KHACHHANG(MA_DVIQLY, MA_KHANG, DCHI, SDT, WEBSITE, EMAIL, NGAY_SINH, FAX, CMT, NGAY_CAP,
                NOI_CAP, "", DateTime.Now, TRANG_THAI, TEN_KHANG, 2);
        }
        public void UPDATE_STATUS_KHACHHANG(string MA_DVIQLY, string MA_KHANG, string DCHI, string SDT, string WEBSITE,
            string EMAIL, DateTime NGAY_SINH, string FAX, string CMT, DateTime NGAY_CAP, string NOI_CAP,
            string TRANG_THAI, string TEN_KHANG)
        {
            CMIS2.DB.THONGTIN_KHACHHANG(MA_DVIQLY, MA_KHANG, DCHI, SDT, WEBSITE, EMAIL, NGAY_SINH, FAX, CMT, NGAY_CAP,
                NOI_CAP, "", DateTime.Now, TRANG_THAI, TEN_KHANG, 3);
        }
        public DataSet SELECT_TNGAN_THONGTIN_KHANG(string ma_dviqly)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_TNGAN_THONGTIN_KHANG(ma_dviqly, out data);
            return data;
        }

        public DataSet SELECT_HDON_CATDIEN(string ma_dviqly, string ma_tngan, DateTime ngay)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_HDON_CATDIEN(ma_dviqly, ma_tngan, ngay, out data);
            return data;
        }

        public DataSet SEARCH_THONGTIN_KHANG(string TU_KHOA, DateTime ngay)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SEARCH_THONGTIN_KHANG(TU_KHOA, ngay, out data);
            return data;
        }

        public DataSet SELECT_ALL_THONGTIN_KHANG(string MA_DVIQLY)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_ALL_THONGTIN_KHANG(MA_DVIQLY, out data);
            return data;
        }
        public DataSet SELECT_ALL_THONGTIN_KHANG_TNGAN(string MA_DVIQLY, string MA_TNGAN)
        {
            DataSet data = new DataSet();
            CMIS2.DB.SELECT_THONGTIN_KHANG_TNGAN(MA_DVIQLY, MA_TNGAN, out data);
            return data;
        }
        #region anhktv
        public DataSet get_DSTHUTIENPHIEUTHU(string strMadvi, string strMatngan, int ithanght, int inamht, DateTime pNgaythu_tu, DateTime pNgaythu_den, int IN_BC)
        {
            DataSet data = new DataSet();
            CMIS2.DB.get_DSTHUTIENPHIEUTHU(strMadvi, strMatngan.ToUpper(), ithanght, inamht, pNgaythu_tu, pNgaythu_den, IN_BC, out data);
            return data;
        }
        #endregion

    }
}
